//tbDict.modify.vue
<template>
  <el-form
      ref="formref"
      :model="formData"
      label-width="auto"
      :inline="true"
  >

    <el-form-item
        label="id" prop="id"   align="center">
      <div slot="label"><span>id</span></div>
      <el-input  v-model="formData['id']"
                 clearable size="mini" style="width:120px"/>
    </el-form-item>
    <el-form-item
        label="name" prop="name"   align="center">
      <div slot="label"><span>name</span></div>
      <el-input  v-model="formData['name']"
                 clearable size="mini" style="width:120px"/>
    </el-form-item>
    <el-form-item
        label="code" prop="code"   align="center">
      <div slot="label"><span>code</span></div>
      <el-input  v-model="formData['code']"
                 clearable size="mini" style="width:120px"/>
    </el-form-item>
    <el-form-item
        label="class_name" prop="class_name"   align="center">
      <div slot="label"><span>class_name</span></div>
      <classSelect
          typeInfo="dic"
          ref="classSelectref"
      :props_select_class_list="[formData]"
                 clearable size="mini" style="width:120px"
                 @change="nodes=>{
                   var node=nodes?.[0]
                    formData.classId=node?.classId
                     formData.className=node?.className
                 }"
                 />
    </el-form-item>

  </el-form>
</template>
<script >
import classSelect from '@/views/components/classselect/classelect.vue'
import axios from 'axios';
import { formData, formMethod, PageData, uniqWithKey } from '@/utils/formcommon';
import { openLayer } from '@/utils/layerdialog/layerdialog';
import { alertConfirm,alertWithPayload } from '@base/utils';
import { lodashFillData } from '@/utils/lodashUtil';
import {tbDict} from './tbDict.json.js'
export default{
  data(){
    return {
      total:0,
      formData:{
        ...tbDict,
        ...PageData,
      },
    };
  },
  components: {
    classSelect,
  },
  methods:{
    ...formMethod,
    async initByDialog(_data){
      if(_data?.row?.id){
        var result=await axios.get(`/api/tb_dict/getbyid?id=${_data?.row?.id}`,{...this.queryParams}).then(res=>res.data);
        var _data2=result?.data;
        lodashFillData(this.formData,_data2)
        console.log("=>[_data2]", _data2);
      }


      this.$nextTick(()=>{
       this.$refs['classSelectref'].dryrun()
      })
    },
    async submitByDialog(){
      //validate
      //data operation
      //ajax 提交
      var url='/api/tb_dict/add'
      if(this.formData?.id){
        url='/api/tb_dict/update'
      }
      var result=await axios.post(url,{...this.formData}).then(res=>res.data)
      alertWithPayload(result)
      return result
    },
  },
};
</script>
